package com.huohuzhihui.web.controller.merchant;

import com.huohuzhihui.common.annotation.Log;
import com.huohuzhihui.common.core.controller.BaseController;
import com.huohuzhihui.common.core.domain.AjaxResult;
import com.huohuzhihui.common.core.page.TableDataInfo;
import com.huohuzhihui.common.enums.BusinessType;
import com.huohuzhihui.common.utils.poi.ExcelUtil;
import com.huohuzhihui.merchant.domain.MerDouyin;
import com.huohuzhihui.merchant.service.IMerDouyinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 商户抖音配置信息Controller
 * 
 * @author huohuzhihui
 * @date 2021-04-03
 */
@RestController
@RequestMapping("/merchant/douyin")
public class MerDouyinController extends BaseController
{
    @Autowired
    private IMerDouyinService merDouyinService;

    /**
     * 查询商户抖音配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:douyin:list')")
    @GetMapping("/list")
    public TableDataInfo list(MerDouyin merDouyin)
    {
        startPage();
        List<MerDouyin> list = merDouyinService.selectMerDouyinList(merDouyin);
        return getDataTable(list);
    }

    /**
     * 导出商户抖音配置信息列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:douyin:export')")
    @Log(title = "商户抖音配置信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MerDouyin merDouyin)
    {
        List<MerDouyin> list = merDouyinService.selectMerDouyinList(merDouyin);
        ExcelUtil<MerDouyin> util = new ExcelUtil<MerDouyin>(MerDouyin.class);
        return util.exportExcel(list, "douyin");
    }

    /**
     * 获取商户抖音配置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:douyin:query')")
    @GetMapping(value = "/{deptId}")
    public AjaxResult getInfo(@PathVariable("deptId") Long id)
    {
        return AjaxResult.success(merDouyinService.selectMerDouyinByDeptId(id));
    }

    /**
     * 新增商户抖音配置信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:douyin:add')")
    @Log(title = "商户抖音配置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerDouyin merDouyin)
    {
        return toAjax(merDouyinService.insertMerDouyin(merDouyin));
    }

    /**
     * 修改商户抖音配置信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:douyin:edit')")
    @Log(title = "商户抖音配置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerDouyin merDouyin)
    {
        return toAjax(merDouyinService.updateMerDouyin(merDouyin));
    }

    /**
     * 删除商户抖音配置信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:douyin:remove')")
    @Log(title = "商户抖音配置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(merDouyinService.deleteMerDouyinByIds(ids));
    }
}
